<!DOCTYPE html>





    

    

    

    

<html lang="en-us">
<!-- Mirrored from docs.memfiredb.com/docs/app/development_guide/auth/auth-helpers/sveltekit/ by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 27 Jun 2025 07:54:00 GMT -->
<head>
    <meta charset="utf-8" />
    <title>使用SveltKit进行Supabase认证 | MemFire Cloud在线文档</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="在SveltKit中实现用户身份验证的方便助手。">
    <meta name="keywords" content="Documentation, Hugo, Hugo Theme, Bootstrap" />
    <meta name="author" content="Colin Wilson - Lotus Labs" />
    <meta name="email" content="support@aigis.uk" />
    <meta name="website" content="https://lotusdocs.dev/" />
    <meta name="Version" content="v0.1.0" />
    
    <link rel="icon" href="https://docs.memfiredb.com/favicon.ico" sizes="any">
<link rel="icon" type="image/svg+xml" href="https://docs.memfiredb.com/favicon.svg">
<link rel="apple-touch-icon" sizes="180x180" href="../../../../../../apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="../../../../../../favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="../../../../../../favicon-16x16.png">
<link rel="manifest" crossorigin="use-credentials" href="https://docs.memfiredb.com/site.webmanifest">
<meta property="og:title" content="使用SveltKit进行Supabase认证" />
<meta property="og:description" content="在SveltKit中实现用户身份验证的方便助手。" />
<meta property="og:type" content="article" />
<meta property="og:url" content="index.html" /><meta property="og:image" content="../../../../../../opengraph/card-base-2_hu06b1a92291a380a0d2e0ec03dab66b2f_17642_filter_3656526475731903457.png"/><meta property="article:section" content="docs" />

<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:image" content="../../../../../../opengraph/card-base-2_hu06b1a92291a380a0d2e0ec03dab66b2f_17642_filter_3656526475731903457.png"/>
<meta name="twitter:title" content="使用SveltKit进行Supabase认证"/>
<meta name="twitter:description" content="在SveltKit中实现用户身份验证的方便助手。"/>

    
    <script>(()=>{var t=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches,e=localStorage.getItem("theme");t&&e===null&&(localStorage.setItem("theme","dark"),document.documentElement.setAttribute("data-dark-mode","")),t&&e==="dark"&&document.documentElement.setAttribute("data-dark-mode",""),e==="dark"&&document.documentElement.setAttribute("data-dark-mode","")})()</script>
    
    
    
    
    
        
        
        
        
    
        
        
        
        
    
    
    <link rel="preconnect" href="https://fonts.gstatic.com/" />
    <link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin />
    <link href="https://fonts.googleapis.com/css?family=Inter:300,400,600,700|Fira+Code:500,700&amp;display=block" rel="stylesheet">

    <link rel="stylesheet" href="../../../../../scss/style.min.3c376716d7676031e43f6cdc5f3b857642dfe5127f5fd4540ab03d9d4fe8ebac97eff815fbd2f0910dd1307fddf53a15.css"  crossorigin="anonymous">
    
    
    
    </head><body>
        <div class="content">
            <div class="page-wrapper toggled">
<nav id="sidebar" class="sidebar-wrapper">
    <div class="sidebar-brand">
        <a href='../../../../../overview/index.html' aria-label="HomePage" alt="HomePage">
            
               <svg width="232" height="20" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 232 20">
  <g fill="none" fill-rule="evenodd">
    <text 
      x="50%" 
      y="50%" 
      font-family="Arial, sans-serif" 
      font-size="18" 
      font-weight="bold" 
      fill="#000" 
      text-anchor="middle" 
      dominant-baseline="middle">
      VFORM
    </text>
  </g>
</svg>
            
        </a>
    </div>
    <div class="sidebar-content" style="height: calc(100% - 131px);">
        <ul class="sidebar-menu">
            
                
                
                    
                        
                        <li class="">
                            <a class="sidebar-root-link" href="../../../../../overview/index.html">
                                <i class="material-icons me-2">dataset</i>
                                
                                文档中心
                            </a>
                        </li>
                    
                
                    
                    
                        <li class="sidebar-dropdown  ">
                            <button class="btn">
                                <i class="material-icons me-2">article</i>
                                产品动向
                            </button>
                            <div class="sidebar-submenu ">
                                <ul>
                                    
                                        
                                        
                                            <li class="sidebar-dropdown nested  ">
                                                <button class="btn">
                                                    
                                                    公告
                                                </button>
                                                <div class="sidebar-submenu ">
                                                    <ul>
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../../announcement/bulletin/bulletins/index.html">【2024年01月03日】MemFire Cloud应用开发正式推出计费套餐</a></li>
                                                            
                                                        
                                                    </ul>
                                                </div>
                                            </li>
                                        
                                    
                                        
                                        
                                            <li class=" "><a class="sidebar-nested-link" href="../../../../../announcement/history/index.html">产品动态</a></li>
                                        
                                    
                                </ul>
                            </div>
                        </li>
                    
                
                    
                    
                        <li class="sidebar-dropdown  current active">
                            <button class="btn">
                                <i class="material-icons me-2">deployed_code</i>
                                应用开发
                            </button>
                            <div class="sidebar-submenu d-block">
                                <ul>
                                    
                                        
                                        
                                            <li class="sidebar-dropdown nested  ">
                                                <button class="btn">
                                                    
                                                    概述
                                                </button>
                                                <div class="sidebar-submenu ">
                                                    <ul>
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../overview/overview/index.html">介绍</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../overview/features/index.html">功能</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../overview/architecture/index.html">架构</a></li>
                                                            
                                                        
                                                    </ul>
                                                </div>
                                            </li>
                                        
                                    
                                        
                                        
                                            <li class="sidebar-dropdown nested  ">
                                                <button class="btn">
                                                    
                                                    购买指南
                                                </button>
                                                <div class="sidebar-submenu ">
                                                    <ul>
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../purchase/price/index.html">价格文档</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../purchase/package/index.html">包年包月套餐说明</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../purchase/arrears/index.html">欠费说明</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../purchase/unsubscribe/index.html">退订说明</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../purchase/qa/index.html">计费相关问题</a></li>
                                                            
                                                        
                                                    </ul>
                                                </div>
                                            </li>
                                        
                                    
                                        
                                        
                                            <li class="sidebar-dropdown nested  ">
                                                <button class="btn">
                                                    
                                                    快速入门
                                                </button>
                                                <div class="sidebar-submenu ">
                                                    <ul>
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../quickstart/with-vue-3/index.html">快速入门: Vue</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../quickstart/with-react/index.html">快速入门: React</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../quickstart/with-flutter/index.html">快速入门: Flutter</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../quickstart/with-nextjs/index.html">快速入门: Next.js</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../quickstart/with-angular/index.html">快速入门: Angular</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../quickstart/with-kotlin/index.html">快速入门: Android Kotlin</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../quickstart/with-nuxt-3/index.html">快速入门: Nuxt 3</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../quickstart/with-svelte/index.html">快速入门: Svelte</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../quickstart/with-ionic-vue/index.html">快速入门: Ionic Vue</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../quickstart/with-expo/index.html">快速入门: Expo</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../quickstart/with-ionic-angular/index.html">快速入门: Ionic Angular</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../quickstart/with-ionic-react/index.html">快速入门: Ionic React</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../quickstart/with-redwoodjs/index.html">快速入门: RedwoodJS</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../quickstart/with-solidjs/index.html">快速入门: SolidJS</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../quickstart/with-sveltekit/index.html">快速入门: SvelteKit</a></li>
                                                            
                                                        
                                                    </ul>
                                                </div>
                                            </li>
                                        
                                    
                                        
                                        
                                            <li class="sidebar-dropdown nested  current active">
                                                <button class="btn">
                                                    
                                                    开发指南
                                                </button>
                                                <div class="sidebar-submenu d-block">
                                                    <ul>
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  current active">
                                                                    <button class="btn">
                                                                        
                                                                        认证
                                                                    </button>
                                                                    <div class="sidebar-submenu d-block">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../auth/index.html">概述</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../redirect-urls/index.html">重定向 URL</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../native-mobile-deep-linking/index.html">原生移动深度链接</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../auth-captcha/index.html">启用Captcha保护</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../rate-limiting/index.html">速率限制</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            快速开始
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../auth-getting-start/nextjs/index.html">Next.js 设置微信扫码登录身份验证</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../auth-getting-start/vue/index.html">vue 设置微信扫码登录身份验证</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            身份验证
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../authentication/auth-email/index.html">使用电子邮件登录</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../authentication/phoneauth/index.html">手机登录认证</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../authentication/wechatauth/index.html">微信小程序登录认证</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../authentication/wechatappauth/index.html">微信移动应用授权登录</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../authentication/wechatqrauth/index.html">微信网站应用扫码登录</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../authentication/auth-magic-link/index.html">使用Magic Link登录</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../authentication/auth-apple/index.html">使用Apple登录</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../authentication/auth-github/index.html">使用GitHub登录</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../authentication/auth-gitlab/index.html">使用GitLab登录</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../authentication/auth-email-templates/index.html">电子邮件模板</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            授权
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../mandates/row-level-security/index.html">行级别安全性</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../mandates/row-level-security2/index.html">RLS使用教程</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../mandates/managing-user-data/index.html">管理用户数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../mandates/server-side-rendering/index.html">服务器端渲染</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../mandates/auth-mfa/index.html">多因素身份验证</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  current active">
                                                                                        <button class="btn">
                                                                                            
                                                                                            认证帮助程序
                                                                                        </button>
                                                                                        <div class="sidebar-submenu d-block">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../auth-helpers/index.html">身份验证帮助程序</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../auth-ui/index.html">身份验证UI</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../nextjs/index.html">使用Next.js进行Supabase认证</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class="current "><a class="sidebar-nested-link" href="index.html">使用SveltKit进行Supabase认证</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../remix/index.html">Supabase Remix认证</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            深层探索
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../auth-deep-dive/auth-deep-dive-jwts/index.html">第一部分:JWTS</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../auth-deep-dive/auth-row-level-security/index.html">第二部分:行级安全</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../auth-deep-dive/auth-policies/index.html">第三部分:策略</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../auth-deep-dive/auth-gotrue/index.html">第四部分: GoTrue</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../auth-deep-dive/auth-google-oauth/index.html">第五部分: Google Oauth</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        数据库
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/database/index.html">概述</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/connecting-to-postgres/index.html">数据库连接</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/associated-query/index.html">关联查询</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/functions/index.html">数据库函数</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/tables/index.html">表格和数据</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/webhooks/index.html">数据库 Webhooks</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/compute-add-ons/index.html">计算附加组件</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            扩展
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/extensions/extensions/index.html">总览</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/extensions/http/index.html">http: RESTful客户端</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/extensions/pgcron/index.html">pg_cron: 作业调度</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/extensions/index_advisor/index.html">index-advisor: 查询优化</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/extensions/pg_graphql/index.html">pg_graphql: 为PostgreSQL提供GraphQL功能</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/extensions/pgvector/index.html">pgvector: 嵌入向量和向量相似性</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/extensions/pgnet/index.html">pg_net: 异步网络</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/extensions/pgtap/index.html">pgTAP:单元测试</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/extensions/plv8/index.html">plv8: JavaScript语言</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/extensions/uuid-ossp/index.html">uuid-ossp: 唯一标识符</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            配置
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/setting/timeouts/index.html">超时</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/setting/replication/index.html">复制</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/setting/managing-passwords/index.html">Passwords</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/setting/managing-timezones/index.html">时区</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/setting/query-optimization/index.html">查询优化</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            FDW
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/wrappers/overview/index.html">外部数据包装器(FDW)</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/wrappers/airtable/index.html">Airtable</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/wrappers/s3/index.html">AWS S3</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/wrappers/bigquery/index.html">BigQuery</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/wrappers/clickhouse/index.html">ClickHouse</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/wrappers/firebase/index.html">Firebase</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/wrappers/logflare/index.html">Logflare</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../database/wrappers/stripe/index.html">Stripe</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        无服务器API
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../api/api/index.html">概述</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../api/quickstart/index.html">2 分钟构建 API 路由</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../api/generating-types/index.html">生成类型</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../api/graphiql/index.html">GraphQL 介绍</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../api/postman/index.html">使用Postman访问数据</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../api/curl/index.html">使用cURL工具访问数据</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../api/securing-your-api/index.html">开始使用</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../api/creating-routes/index.html">创建 API 路由</a></li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        云函数
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../functions/overview/index.html">概述</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../functions/function-management/index.html">管理函数</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../functions/code-development/index.html">代码开发</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../functions/fn-local-test/index.html">云函数本地调试</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../functions/variable/index.html">环境变量</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            函数示例
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../functions/functionexample/helloworld/index.html">helloworld</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../functions/functionexample/wechatpay/index.html">wechatpay</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../functions/functionexample/raffle/index.html">抽奖示例</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        实时数据库
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../realtime/realtime/index.html">实时</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../realtime/quickstart/index.html">实时快速入门</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../realtime/postgres-cdc/index.html">Postgres CDC</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../realtime/rate-limits/index.html">实时速率限制</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../realtime/concepts/index.html">实时概念</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            用法
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../realtime/usage/broadcast/index.html">广播</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../realtime/usage/presence/index.html">Presence </a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            指南
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../realtime/guides/client-side-throttling/index.html">限制消息</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../realtime/guides/postgres-changes/index.html">Postgres 更改</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../realtime/guides/realtime-with-nextjs/index.html">将 Realtime 与 Next.js 结合使用</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../realtime/guides/subscribing-to-database-changes/index.html">订阅数据库更改</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            深入了解
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../realtime/deep-dive/architecture/index.html">实时架构</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../realtime/deep-dive/bring-your-own-database/index.html">自带数据库</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../realtime/deep-dive/protocol/index.html">实时协议</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../realtime/deep-dive/quotas/index.html">实时配额</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        对象存储
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../storage/storage/index.html">概述</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../storage/storage-cdn/index.html">存储CDN</a></li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        AI 和 Vectors
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../ai/ai/index.html">总览</a></li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        静态托管
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../hosting/static-hosting/index.html">静态托管</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../hosting/static-start/index.html">快速开始</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../hosting/static-domain/index.html">自定义域名</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../hosting/real-name-authentication/index.html">实名认证</a></li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                    </ul>
                                                </div>
                                            </li>
                                        
                                    
                                        
                                        
                                            <li class="sidebar-dropdown nested  ">
                                                <button class="btn">
                                                    
                                                    SDK文档
                                                </button>
                                                <div class="sidebar-submenu ">
                                                    <ul>
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        JavaScript
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            开始
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/start/javascript/index.html">JavaScript库</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/start/installing/index.html">安装</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/start/initializing/index.html">初始化客户端</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/start/typescript-support/index.html">支持Typescript</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/start/release-notes/index.html">版本说明</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            数据库
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/database/select/index.html">Select 查询</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/database/insert/index.html">Insert 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/database/update/index.html">Update 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/database/upsert/index.html">Upsert 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/database/delete/index.html">Delete 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/database/rpc/index.html">调用Postgres函数</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/database/filter/index.html">过滤器</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/database/modifier/index.html">修改器</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            认证
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/auth/auth-api/index.html">概述</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/auth/auth-signup/index.html">signUp()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/auth/auth-signinwithpassword/index.html">signInWithPassword()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/auth/auth-signinwithotp/index.html">signInWithOtp()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/auth/auth-signinwithoauth/index.html">signInWithOAuth()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/auth/auth-signout/index.html">signOut()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/auth/auth-resetpasswordforemail/index.html">resetPasswordForEmail()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/auth/auth-verifyotp/index.html">通过 OTP 进行验证和登录</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/auth/auth-getsession/index.html">getSession()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/auth/auth-refreshsession/index.html">refreshSession()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/auth/auth-getuser/index.html">getUser()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/auth/auth-updateuser/index.html">updateUser()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/auth/auth-setsession/index.html">setSession()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/auth/auth-onauthstatechange/index.html">onAuthStateChange()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            认证（仅限服务端）
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/auth-admin/supabase-auth-admin-api/index.html">概览</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/auth-admin/auth-admin-getuserbyid/index.html">getUserById()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/auth-admin/auth-admin-listusers/index.html">listUsers()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/auth-admin/auth-admin-createuser/index.html">createUser()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/auth-admin/auth-admin-deleteuser/index.html">deleteUser()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/auth-admin/auth-admin-inviteuserbyemail/index.html">inviteUserByEmail()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/auth-admin/auth-admin-generatelink/index.html">generateLink()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/auth-admin/auth-admin-updateuserbyid/index.html">updateUserById()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            函数
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/function/invoke/index.html">invoke()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            实时数据库
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/realtime/subscribe/index.html">on().subscribe()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/realtime/removechannel/index.html">removeChannel()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/realtime/removeallchannels/index.html">removeAllChannels()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/realtime/getchannels/index.html">getChannels()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            对象存储
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/storage/storage-createbucket/index.html">createBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/storage/storage-deletebucket/index.html">deleteBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/storage/storage-from-download/index.html">from.download()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/storage/storage-from-upload/index.html">from.upload()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/storage/storage-from-update/index.html">from.update()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/storage/storage-from-remove/index.html">from.remove()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/storage/storage-from-list/index.html">from.list()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/storage/storage-from-move/index.html">from.move()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/storage/storage-from-copy/index.html">from.copy()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/storage/storage-from-createsignedurl/index.html">from.createSignedUrl()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/storage/storage-from-createsignedurls/index.html">from.createSignedUrls()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/storage/storage-from-getpublicurl/index.html">from.getPublicUrl()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/storage/storage-emptybucket/index.html">emptyBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/storage/storage-getbucket/index.html">getBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/storage/storage-listbuckets/index.html">listBuckets()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/javascript/storage/storage-updatebucket/index.html">updateBucket()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        Flutter
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            开始
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/start/dart/index.html">Flutter库</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/start/initializing/index.html">初始化</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/start/installing/index.html">安装</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/start/upgrade-guide/index.html">更新</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            数据库
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/database/select/index.html">Select 查询</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/database/insert/index.html">Insert 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/database/update/index.html">Update 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/database/upsert/index.html">Upsert 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/database/delete/index.html">Delete 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/database/rpc/index.html">存储程序: rpc()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/database/filter/index.html">过滤器</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/database/modifier/index.html">修改器</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            认证
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/auth/auth-signup/index.html">signUp()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/auth/auth-signinwithpassword/index.html">signInWithPassword()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/auth/auth-signinwithotp/index.html">signInWithOtp()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/auth/auth-signinwithoauth/index.html">signInWithOAuth()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/auth/auth-signout/index.html">signOut()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/auth/auth-verifyotp/index.html">verifyOtp()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/auth/auth-currentsession/index.html">currentSession</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/auth/auth-currentuser/index.html">currentUser</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/auth/auth-updateuser/index.html">updateUser()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/auth/auth-onauthstatechange/index.html">onAuthStateChange()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/auth/auth-resetpasswordforemail/index.html">resetPasswordForEmail()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            函数
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/function/invoke/index.html">待补充</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            实时数据库
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/realtime/stream/index.html">stream()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/realtime/subscribe/index.html">on().subscribe()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/realtime/removechannel/index.html">removeChannel()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/realtime/removeallchannels/index.html">removeAllChannels()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/realtime/getchannels/index.html">getChannels()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            对象存储
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/storage/storage-createbucket/index.html">createBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/storage/storage-getbucket/index.html">getBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/storage/storage-listbuckets/index.html">listBuckets()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/storage/storage-updatebucket/index.html">updateBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/storage/storage-deletebucket/index.html">deleteBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/storage/storage-emptybucket/index.html">emptyBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/storage/storage-from-upload/index.html">from.upload()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/storage/storage-from-download/index.html">from.download()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/storage/storage-from-list/index.html">from.list()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/storage/storage-from-update/index.html">from.update()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/storage/storage-from-move/index.html">from.move()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/storage/storage-from-remove/index.html">from.remove()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/storage/storage-from-createsignedurl/index.html">from.createSignedUrl()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/storage/storage-from-createsignedurls/index.html">from.createSignedUrls()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/dart/storage/storage-from-getpublicurl/index.html">from.getPublicUrl()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        微信小程序
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            开始
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/start/wechat/index.html">微信小程序客户端</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/start/installing/index.html">安装</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/start/initializing/index.html">初始化客户端</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/start/typescript-support/index.html">支持Typescript</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/start/release-notes/index.html">版本说明</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            数据库
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/database/select/index.html">Select 查询</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/database/insert/index.html">Insert 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/database/update/index.html">Update 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/database/upsert/index.html">Upsert 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/database/delete/index.html">Delete 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/database/rpc/index.html">调用Postgres函数</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/database/filter/index.html">过滤器</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/database/modifier/index.html">修改器</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            认证
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth/auth-api/index.html">概述</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth/auth-signinwithwechat/index.html">signInWithWechat()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth/auth-wechatbindphone/index.html">getUnlimitedQRCode()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth/auth-getunlimitedqrcode/index.html">signInWithWechat()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth/auth-wechatbindaccount/index.html">wechatBindAccount()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth/auth-updateuser/index.html">updateUser()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth/auth-signup/index.html">signUp()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth/auth-signinwithpassword/index.html">signInWithPassword()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth/auth-signinwithotp/index.html">signInWithOtp()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth/auth-signinwithoauth/index.html">signInWithOAuth()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth/auth-signout/index.html">signOut()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth/auth-verifyotp/index.html">通过 OTP 进行验证和登录</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth/auth-getsession/index.html">getSession()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth/auth-refreshsession/index.html">refreshSession()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth/auth-getuser/index.html">getUser()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth/auth-setsession/index.html">setSession()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth/auth-onauthstatechange/index.html">onAuthStateChange()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth/auth-resetpasswordforemail/index.html">resetPasswordForEmail()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            认证（仅限服务端）
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth-admin/auth-admin-listusers/index.html">listUsers()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth-admin/supabase-auth-admin-api/index.html">概览</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth-admin/auth-admin-createuser/index.html">createUser()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth-admin/auth-admin-deleteuser/index.html">deleteUser()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth-admin/auth-admin-generatelink/index.html">generateLink()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth-admin/auth-admin-inviteuserbyemail/index.html">inviteUserByEmail()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth-admin/auth-admin-getuserbyid/index.html">getUserById()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/auth-admin/auth-admin-updateuserbyid/index.html">updateUserById()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            函数
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/function/invoke/index.html">invoke()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            实时数据库
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/realtime/subscribe/index.html">on().subscribe()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/realtime/removechannel/index.html">removeChannel()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/realtime/removeallchannels/index.html">removeAllChannels()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/realtime/getchannels/index.html">getChannels()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            对象存储
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/storage/storage-createbucket/index.html">createBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/storage/storage-getbucket/index.html">getBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/storage/storage-listbuckets/index.html">listBuckets()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/storage/storage-updatebucket/index.html">updateBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/storage/storage-deletebucket/index.html">deleteBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/storage/storage-emptybucket/index.html">emptyBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/storage/storage-from-upload/index.html">from.upload()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/storage/storage-from-download/index.html">from.download()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/storage/storage-from-list/index.html">from.list()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/storage/storage-from-update/index.html">from.update()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/storage/storage-from-move/index.html">from.move()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/storage/storage-from-copy/index.html">from.copy()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/storage/storage-from-remove/index.html">from.remove()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/storage/storage-from-createsignedurl/index.html">from.createSignedUrl()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/storage/storage-from-createsignedurls/index.html">from.createSignedUrls()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../sdkdocs/wechatsdk/storage/storage-from-getpublicurl/index.html">from.getPublicUrl()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                    </ul>
                                                </div>
                                            </li>
                                        
                                    
                                        
                                        
                                            <li class="sidebar-dropdown nested  ">
                                                <button class="btn">
                                                    
                                                    最佳实践
                                                </button>
                                                <div class="sidebar-submenu ">
                                                    <ul>
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../example/scaffold/index.html">前端框架的脚手架</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        微信小程序
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../example/wechat/timetable/index.html">Super课表小程序</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../example/wechat/hellobbs/index.html">BBS论坛小程序</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../example/wechat/notclickwhite/index.html">别踩白块游戏小程序</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../example/wechat/wechatroom/index.html">微信小程序聊天室</a></li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        Web
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../example/web/postsforum/index.html">Posts社交网络论坛</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../../example/web/playground/index.html">实时游戏场</a></li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                    </ul>
                                                </div>
                                            </li>
                                        
                                    
                                </ul>
                            </div>
                        </li>
                    
                
                    
                    
                        <li class="sidebar-dropdown  ">
                            <button class="btn">
                                <i class="material-icons me-2">database</i>
                                云数据库
                            </button>
                            <div class="sidebar-submenu ">
                                <ul>
                                    
                                        
                                        
                                            <li class=" "><a class="sidebar-nested-link" href="../../../../../db/db-introduction/index.html">介绍</a></li>
                                        
                                    
                                        
                                        
                                            <li class=" "><a class="sidebar-nested-link" href="../../../../../db/database-management/index.html">数据库管理</a></li>
                                        
                                    
                                        
                                        
                                            <li class=" "><a class="sidebar-nested-link" href="../../../../../db/account-management/index.html">账号管理</a></li>
                                        
                                    
                                        
                                        
                                            <li class=" "><a class="sidebar-nested-link" href="../../../../../db/backup-and-recovery/index.html">备份恢复</a></li>
                                        
                                    
                                        
                                        
                                            <li class=" "><a class="sidebar-nested-link" href="../../../../../db/online-sql-editor/index.html">在线SQL编辑器</a></li>
                                        
                                    
                                        
                                        
                                            <li class=" "><a class="sidebar-nested-link" href="../../../../../db/client-connection/index.html">客户端工具</a></li>
                                        
                                    
                                        
                                        
                                            <li class=" "><a class="sidebar-nested-link" href="../../../../../db/introduction-to-sql-operation/index.html">SQL操作入门</a></li>
                                        
                                    
                                        
                                        
                                            <li class="sidebar-dropdown nested  ">
                                                <button class="btn">
                                                    
                                                    开发示例
                                                </button>
                                                <div class="sidebar-submenu ">
                                                    <ul>
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../../db/example/python-example/index.html">Python2示例</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../../db/example/python3-example/index.html">Python3示例</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../../db/example/java-example/index.html">Java示例</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../../db/example/golang-example/index.html">Golang示例</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../../db/example/spring-example/index.html">Spring示例</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../../db/example/node-example/index.html">Node示例</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../../db/example/c%2b%2b-example/index.html">C&#43;&#43;示例</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../../db/example/c-example/index.html">C#示例</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../../db/example/c2-example/index.html">C示例</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../../db/example/development-example/index.html"></a></li>
                                                            
                                                        
                                                    </ul>
                                                </div>
                                            </li>
                                        
                                    
                                        
                                        
                                            <li class=" "><a class="sidebar-nested-link" href="../../../../../db/memfiredb-data-migration/index.html">数据迁移</a></li>
                                        
                                    
                                        
                                        
                                            <li class="sidebar-dropdown nested  ">
                                                <button class="btn">
                                                    
                                                    参考指南
                                                </button>
                                                <div class="sidebar-submenu ">
                                                    <ul>
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../../db/guides/compatibility/index.html">兼容性说明</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../../db/guides/keyword/index.html">关键字</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../../db/guides/data-type/index.html">数据类型</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../../db/guides/sql-grammar/index.html">SQL语法</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../../../db/guides/functions-and-operations/index.html">函数与操作</a></li>
                                                            
                                                        
                                                    </ul>
                                                </div>
                                            </li>
                                        
                                    
                                </ul>
                            </div>
                        </li>
                    
                
                    
                        
                        <li class="">
                            <a class="sidebar-root-link" href="../../../../../contactus/index.html">
                                <i class="material-icons me-2">article</i>
                                
                                联系我们
                            </a>
                        </li>
                    
                
                    
                        
                        <li class="">
                            <a class="sidebar-root-link" href="../../../../../frequently-asked-questions/index.html">
                                <i class="material-icons me-2">quiz</i>
                                
                                常见问题解答（FAQ）
                            </a>
                        </li>
                    
                
            
        </ul>
        
    </div>
    
        <ul class="sidebar-footer list-unstyled mb-0">
            
        </ul>
    
</nav>

                    <main class="page-content bg-transparent">
                        
<div id="top-header" class="top-header d-print-none">
    <div class="header-bar d-flex justify-content-between">
        <div class="d-flex align-items-center">
            <a href='https://docs.memfiredb.com/' class="logo-icon me-3" aria-label="HomePage" alt="HomePage">
                <div class="small">
                    
                            <?xml version="1.0" encoding="UTF-8"?>
<svg width="99px" height="112px" viewBox="0 0 99 112" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <title>MemFireDB备份 6</title>
    <defs>
        <linearGradient x1="49.9999885%" y1="98.082503%" x2="49.9999885%" y2="0.766550128%" id="linearGradient-1">
            <stop stop-color="#ED1C23" offset="0%"></stop>
            <stop stop-color="#FBAF3B" offset="100%"></stop>
        </linearGradient>
    </defs>
    <g id="定稿" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
        <g id="MemFireDB备份-6">
            <polygon id="Fill-1" fill="#F9AE7C" points="25.9728553 40.7912363 47.4268317 0.00591833831 1.15453123 26.7215251"></polygon>
            <polygon id="Fill-3" fill="#F9AE7C" points="97.4213117 26.7267606 51.1285247 0.000910513587 72.4242993 40.8351686"></polygon>
            <polygon id="Fill-5" fill="#F9904A" points="24.8347133 42.7618153 0.000455256793 28.682999 0.000455256793 82.1608764"></polygon>
            <polygon id="Fill-7" fill="url(#linearGradient-1)" points="27.6634514 42.4662399 49.279044 109.05096 70.7296059 42.507213 49.2779058 1.3747617"></polygon>
            <polygon id="Fill-9" fill="#F9904A" points="98.5660549 28.6951771 73.5622137 42.8047233 98.5660549 82.1719163"></polygon>
            <polygon id="Fill-13" fill="#FB6D33" points="72.2987623 45.061545 50.7514582 111.900071 97.579172 84.8646465"></polygon>
            <polygon id="Fill-15" fill="#FB6D33" points="26.1006687 45.0226206 0.987565799 84.8644188 47.8095888 111.898705"></polygon>
            <path d="M60.0737516,38.507213 C59.3168872,35.669825 57.0462939,33.3514298 57.0462939,33.3514298 C57.0462939,33.3514298 57.0804382,35.8849338 56.2894295,37.513615 C55.4847631,39.1696116 53.8765685,40.3054773 53.8765685,40.3054773 C53.8765685,40.3054773 56.1016361,33.8840802 54.2715038,30.1247973 C52.0259496,25.5073552 49.1771803,23.3357803 49.1771803,23.3357803 C49.1771803,23.3357803 50.1070423,28.1319107 48.6240432,31.5065016 C47.1672215,34.8264618 42.8058614,36.7260208 40.7241997,38.7132167 C39.1865699,40.1791435 38.0814341,43.0711623 37.6068289,44.4847347 C37.5715465,44.5883056 37.560165,44.6918765 37.5533362,44.7943093 C37.584066,43.9816759 37.8890881,39.8024186 40.9654858,37.4293925 C43.8404325,35.2111538 41.2431925,30.3478731 41.2431925,30.3478731 C41.2431925,30.3478731 41.7212121,32.5638355 40.9939394,34.1401622 C40.2655285,35.7153507 38.7187936,36.5962726 38.0154218,38.259098 C37.3883056,39.7409589 37.5203301,44.1432921 37.5453692,44.8409731 C37.5453692,44.8591834 37.5476455,44.8762555 37.5476455,44.8921895 C37.5476455,44.9263338 37.5487836,44.9456822 37.5487836,44.9456822 L37.5487836,44.9115379 C37.5590269,45.2655001 37.7138142,45.6080808 37.9972116,45.8448143 L48.3713757,55.6442168 C48.8380139,56.0323232 49.5163466,56.0334614 49.9841229,55.6476312 L60.5938825,45.7105136 C60.9034571,45.4544316 61.0719021,45.0686015 61.0457249,44.6656992 C60.9546735,43.2282259 60.5699815,40.3692133 60.0737516,38.507213" id="Fill-17" fill="#FFFFFF"></path>
        </g>
    </g>
</svg>
                    
                </div>
                <div class="big">
                    
                           <svg width="232" height="20" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 232 20">
  <g fill="none" fill-rule="evenodd">
    <text 
      x="50%" 
      y="50%" 
      font-family="Arial, sans-serif" 
      font-size="18" 
      font-weight="bold" 
      fill="#000" 
      text-anchor="middle" 
      dominant-baseline="middle">
      VFORM
    </text>
  </g>
</svg>
                    
                </div>
            </a>
            <button id="close-sidebar" class="btn btn-icon btn-soft">
                <span class="material-icons size-20 menu-icon align-middle">menu</span>
            </button>
            
            </div>

        <div class="d-flex align-items-center">
            <ul class="list-unstyled mb-0">
                
            </ul>
            <a  class="btn btn-icon btn-default ms-4"  type="button" href="https://memfiredb.com/"  target="_blank" >官网</a>
            <a  class="btn btn-icon btn-default ms-4" type="button" href="https://community.memfiredb.com/"  target="_blank"  >论坛</a>
            <a  class="btn btn-icon btn-default ms-4" type="button" href="https://cloud.memfiredb.com/auth/login"  target="_blank"  >登录</a>
            <button id="mode" class="btn btn-icon btn-default ms-2" type="button" aria-label="Toggle user interface mode">
                <span class="toggle-dark">
                    <svg xmlns="http://www.w3.org/2000/svg" height="30" width="30" viewBox="0 0 48 48" fill="currentColor">
                        <title>Enable dark mode</title>
                        <path d="M24 42q-7.5 0-12.75-5.25T6 24q0-7.5 5.25-12.75T24 6q.4 0 .85.025.45.025 1.15.075-1.8 1.6-2.8 3.95-1 2.35-1 4.95 0 4.5 3.15 7.65Q28.5 25.8 33 25.8q2.6 0 4.95-.925T41.9 22.3q.05.6.075.975Q42 23.65 42 24q0 7.5-5.25 12.75T24 42Zm0-3q5.45 0 9.5-3.375t5.05-7.925q-1.25.55-2.675.825Q34.45 28.8 33 28.8q-5.75 0-9.775-4.025T19.2 15q0-1.2.25-2.575.25-1.375.9-3.125-4.9 1.35-8.125 5.475Q9 18.9 9 24q0 6.25 4.375 10.625T24 39Zm-.2-14.85Z"/>
                    </svg>
                </span>
                <span class="toggle-light">
                    <svg xmlns="http://www.w3.org/2000/svg" height="30" width="30" viewBox="0 0 48 48" fill="currentColor">
                        <title>Enable light mode</title>
                        <path d="M24 31q2.9 0 4.95-2.05Q31 26.9 31 24q0-2.9-2.05-4.95Q26.9 17 24 17q-2.9 0-4.95 2.05Q17 21.1 17 24q0 2.9 2.05 4.95Q21.1 31 24 31Zm0 3q-4.15 0-7.075-2.925T14 24q0-4.15 2.925-7.075T24 14q4.15 0 7.075 2.925T34 24q0 4.15-2.925 7.075T24 34ZM3.5 25.5q-.65 0-1.075-.425Q2 24.65 2 24q0-.65.425-1.075Q2.85 22.5 3.5 22.5h5q.65 0 1.075.425Q10 23.35 10 24q0 .65-.425 1.075-.425.425-1.075.425Zm36 0q-.65 0-1.075-.425Q38 24.65 38 24q0-.65.425-1.075.425-.425 1.075-.425h5q.65 0 1.075.425Q46 23.35 46 24q0 .65-.425 1.075-.425.425-1.075.425ZM24 10q-.65 0-1.075-.425Q22.5 9.15 22.5 8.5v-5q0-.65.425-1.075Q23.35 2 24 2q.65 0 1.075.425.425.425.425 1.075v5q0 .65-.425 1.075Q24.65 10 24 10Zm0 36q-.65 0-1.075-.425-.425-.425-.425-1.075v-5q0-.65.425-1.075Q23.35 38 24 38q.65 0 1.075.425.425.425.425 1.075v5q0 .65-.425 1.075Q24.65 46 24 46ZM12 14.1l-2.85-2.8q-.45-.45-.425-1.075.025-.625.425-1.075.45-.45 1.075-.45t1.075.45L14.1 12q.4.45.4 1.05 0 .6-.4 1-.4.45-1.025.45-.625 0-1.075-.4Zm24.7 24.75L33.9 36q-.4-.45-.4-1.075t.45-1.025q.4-.45 1-.45t1.05.45l2.85 2.8q.45.45.425 1.075-.025.625-.425 1.075-.45.45-1.075.45t-1.075-.45ZM33.9 14.1q-.45-.45-.45-1.05 0-.6.45-1.05l2.8-2.85q.45-.45 1.075-.425.625.025 1.075.425.45.45.45 1.075t-.45 1.075L36 14.1q-.4.4-1.025.4-.625 0-1.075-.4ZM9.15 38.85q-.45-.45-.45-1.075t.45-1.075L12 33.9q.45-.45 1.05-.45.6 0 1.05.45.45.45.45 1.05 0 .6-.45 1.05l-2.8 2.85q-.45.45-1.075.425-.625-.025-1.075-.425ZM24 24Z"/>
                    </svg>
                </span>
            </button>
            
        </div>
    </div>
    
    
    
</div>

                            <div class="container-fluid">
                                <div class="layout-spacing">
                                    
                                        <div class="d-md-flex justify-content-between align-items-center"><nav aria-label="breadcrumb" class="d-inline-block pb-2 mt-1 mt-sm-0">
    <ul id="breadcrumbs" class="breadcrumb bg-transparent mb-0" itemscope itemtype="https://schema.org/BreadcrumbList">
        
            
                <li class="breadcrumb-item text-capitalize active" aria-current="page" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
                    <a itemprop="item" href="../../../../../index.html">
                        <i class="material-icons size-20 align-text-bottom" itemprop="name">Home</i>
                    </a>
                    <meta itemprop="position" content='1' />
                </li>
            
            
                <li class="breadcrumb-item text-capitalize" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
                    <a itemprop="item" href="../../../../index.html">
                        <span itemprop="name">应用开发</span>
                    </a>
                    <meta itemprop="position" content='2' />
                </li>
            
            
                <li class="breadcrumb-item text-capitalize" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
                    <a itemprop="item" href="../../../index.html">
                        <span itemprop="name">开发指南</span>
                    </a>
                    <meta itemprop="position" content='3' />
                </li>
            
            
                <li class="breadcrumb-item text-capitalize" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
                    <a itemprop="item" href="../../index.html">
                        <span itemprop="name">认证</span>
                    </a>
                    <meta itemprop="position" content='4' />
                </li>
            
            
                <li class="breadcrumb-item text-capitalize" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
                    <a itemprop="item" href="../index.html">
                        <span itemprop="name">认证帮助程序</span>
                    </a>
                    <meta itemprop="position" content='5' />
                </li>
            
        
            <li class="breadcrumb-item text-capitalize active" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
                <span itemprop="name">使用SveltKit进行Supabase认证</span>
                <meta itemprop="position" content='6' />
            </li>
        
    </ul>
</nav></div>
                                    
                                    <div class="row flex-xl-nowrap">
                                        
                                        <div class="docs-toc col-xl-3    d-xl-block"><toc>
    <div class="fw-bold text-uppercase mb-2">本页</div>
    <nav id="toc">
  <ul>
    <li>
      <ul>
        <li><a href="#安装">安装</a></li>
        <li><a href="#入门">入门</a>
          <ul>
            <li><a href="#配置">配置</a></li>
            <li><a href="#设置suabase客户端">设置Suabase客户端</a></li>
            <li><a href="#同步页面存储">同步页面存储</a></li>
            <li><a href="#向客户端发送会话">向客户端发送会话</a></li>
            <li><a href="#键入">键入</a></li>
            <li><a href="#基本设置">基本设置</a></li>
          </ul>
        </li>
        <li><a href="#使用rls获取客户端数据">使用RLS获取客户端数据</a></li>
        <li><a href="#使用rls获取服务器端数据">使用RLS获取服务器端数据</a></li>
        <li><a href="#保护api路由">保护API路由</a></li>
        <li><a href="#保护措施">保护措施</a></li>
        <li><a href="#保存和删除会话">保存和删除会话</a></li>
        <li><a href="#保护多条路线">保护多条路线</a></li>
        <li><a href="#migration">从0.7.x迁移到0.8</a>
          <ul>
            <li><a href="#migration-set-up-supabase-client">设置Supabase客户端</a></li>
            <li><a href="#migration-initialize-client">初始化客户端</a></li>
            <li><a href="#migration-set-up-hooks">设置挂钩</a></li>
            <li><a href="#migration-typings">键入</a></li>
            <li><a href="#migration-with-page-auth">withPageAuth</a></li>
            <li><a href="#migration-with-api-auth">withApiAuth</a></li>
          </ul>
        </li>
        <li><a href="#migration-0-7">从0.6.11及以下迁移到0.7.0</a>
          <ul>
            <li><a href="#环境变量前缀">环境变量前缀</a></li>
            <li><a href="#migration-set-up-supabase-client-0-7">设置Supabase客户端</a></li>
            <li><a href="#migration-initialize-client-0-7">初始化客户端</a></li>
            <li><a href="#migration-set-up-hooks-0-7">设置挂钩</a></li>
            <li><a href="#migration-typings-0-7">键入</a></li>
            <li><a href="#检查客户端上的用户">检查客户端上的用户</a></li>
            <li><a href="#withpageauth">withPageAuth</a></li>
            <li><a href="#withapiauth">withApiAuth</a></li>
          </ul>
        </li>
        <li><a href="#其他链接">其他链接</a></li>
      </ul>
    </li>
  </ul>
</nav>
    </toc></div>
                                        
                                        
                                        <div class="docs-toc-mobile    d-print-none d-xl-none">
                                            <button id="toc-dropdown-btn" class="btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" data-bs-offset="0,0" aria-expanded="false">
                                                Table of Contents
                                            </button>
<nav id="toc-mobile">
  <ul class="dropdown-menu">
    <li>
      <ul>
        <li><a href="#安装">安装</a></li>
        <li><a href="#入门">入门</a>
          <ul>
            <li><a href="#配置">配置</a></li>
            <li><a href="#设置suabase客户端">设置Suabase客户端</a></li>
            <li><a href="#同步页面存储">同步页面存储</a></li>
            <li><a href="#向客户端发送会话">向客户端发送会话</a></li>
            <li><a href="#键入">键入</a></li>
            <li><a href="#基本设置">基本设置</a></li>
          </ul>
        </li>
        <li><a href="#使用rls获取客户端数据">使用RLS获取客户端数据</a></li>
        <li><a href="#使用rls获取服务器端数据">使用RLS获取服务器端数据</a></li>
        <li><a href="#保护api路由">保护API路由</a></li>
        <li><a href="#保护措施">保护措施</a></li>
        <li><a href="#保存和删除会话">保存和删除会话</a></li>
        <li><a href="#保护多条路线">保护多条路线</a></li>
        <li><a href="#migration">从0.7.x迁移到0.8</a>
          <ul>
            <li><a href="#migration-set-up-supabase-client">设置Supabase客户端</a></li>
            <li><a href="#migration-initialize-client">初始化客户端</a></li>
            <li><a href="#migration-set-up-hooks">设置挂钩</a></li>
            <li><a href="#migration-typings">键入</a></li>
            <li><a href="#migration-with-page-auth">withPageAuth</a></li>
            <li><a href="#migration-with-api-auth">withApiAuth</a></li>
          </ul>
        </li>
        <li><a href="#migration-0-7">从0.6.11及以下迁移到0.7.0</a>
          <ul>
            <li><a href="#环境变量前缀">环境变量前缀</a></li>
            <li><a href="#migration-set-up-supabase-client-0-7">设置Supabase客户端</a></li>
            <li><a href="#migration-initialize-client-0-7">初始化客户端</a></li>
            <li><a href="#migration-set-up-hooks-0-7">设置挂钩</a></li>
            <li><a href="#migration-typings-0-7">键入</a></li>
            <li><a href="#检查客户端上的用户">检查客户端上的用户</a></li>
            <li><a href="#withpageauth">withPageAuth</a></li>
            <li><a href="#withapiauth">withApiAuth</a></li>
          </ul>
        </li>
        <li><a href="#其他链接">其他链接</a></li>
      </ul>
    </li>
  </ul>
</nav></div>
                                        <div class="docs-content col-12 col-xl-9 mt-0">
                                            <div class="mb-0 d-flex">
                                                
                                                <h1 class="content-title mb-0">
                                                    使用SveltKit进行Supabase认证
                                                    
                                                </h1>
                                            </div>
                                            
                                            <div id="content" class="main-content" data-bs-spy="scroll" data-bs-root-margin="0px 0px -65%" data-bs-target="#toc-mobile">
                                                
    
    <div data-prismjs-copy="" data-prismjs-copy-success="" data-prismjs-copy-error="">
        <p>该子模块提供了在<a href="https://kit.svelte.dev/" rel="external" target="_blank">SvelteKit<svg width="16" height="16" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M14 5c-.552 0-1-.448-1-1s.448-1 1-1h6c.552 0 1 .448 1 1v6c0 .552-.448 1-1 1s-1-.448-1-1v-3.586l-7.293 7.293c-.391.39-1.024.39-1.414 0-.391-.391-.391-1.024 0-1.414l7.293-7.293h-3.586zm-9 2c-.552 0-1 .448-1 1v11c0 .552.448 1 1 1h11c.552 0 1-.448 1-1v-4.563c0-.552.448-1 1-1s1 .448 1 1v4.563c0 1.657-1.343 3-3 3h-11c-1.657 0-3-1.343-3-3v-11c0-1.657 1.343-3 3-3h4.563c.552 0 1 .448 1 1s-.448 1-1 1h-4.563z"/></svg></a>中实现用户身份验证的方便助手应用程序。</p>
<h2 id="安装">安装 <a href="#%e5%ae%89%e8%a3%85" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p>此库支持Node.js<code>^16.15.0</code>。</p>

<nav>
	<div class="nav nav-tabs" id="nav-tab" role="tablist">

		
		
		
		

		

		<a class="nav-link  active"
		   id="efdbacTab" data-bs-toggle="tab" data-bs-target="#efdbac"
		   type="button" role="tab" aria-controls="efdbac" aria-selected="true">npm</a>

		

		<a class="nav-link "
		   id="fdebacTab" data-bs-toggle="tab" data-bs-target="#fdebac"
		   type="button" role="tab" aria-controls="fdebac" aria-selected="true">Yarn</a>

		

	</div>
</nav>

<div class="tab-content" id="nav-tab-content">

	






<div class="tab-pane fade show active" id="efdbac" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="acf76e8" class="language-sh ">
  <code>npm install @supabase/auth-helpers-sveltekit</code>
  </pre>
  </div>


</div>






<div class="tab-pane fade" id="fdebac" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="fe15870" class="language-sh ">
  <code>yarn add @supabase/auth-helpers-sveltekit</code>
  </pre>
  </div>


</div>


</div>
<h2 id="入门">入门 <a href="#%e5%85%a5%e9%97%a8" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><h3 id="配置">配置 <a href="#%e9%85%8d%e7%bd%ae" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h3><p>设置填充环境变量。对于本地开发，您可以将其设置为<code>.env</code>文件。参见<a href="https://github.com/supabase/auth-helpers/blob/main/examples/sveltekit/.env.example" rel="external" target="_blank">示例<svg width="16" height="16" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M14 5c-.552 0-1-.448-1-1s.448-1 1-1h6c.552 0 1 .448 1 1v6c0 .552-.448 1-1 1s-1-.448-1-1v-3.586l-7.293 7.293c-.391.39-1.024.39-1.414 0-.391-.391-.391-1.024 0-1.414l7.293-7.293h-3.586zm-9 2c-.552 0-1 .448-1 1v11c0 .552.448 1 1 1h11c.552 0 1-.448 1-1v-4.563c0-.552.448-1 1-1s1 .448 1 1v4.563c0 1.657-1.343 3-3 3h-11c-1.657 0-3-1.343-3-3v-11c0-1.657 1.343-3 3-3h4.563c.552 0 1 .448 1 1s-.448 1-1 1h-4.563z"/></svg></a>.</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="837a41d" class="language-bash ">
  <code># Find these in your Supabase project settings &gt; API
PUBLIC_SUPABASE_URL=https://your-project.supabase.co
PUBLIC_SUPABASE_ANON_KEY=your-anon-key</code>
  </pre>
  </div>
<h3 id="设置suabase客户端">设置Suabase客户端 <a href="#%e8%ae%be%e7%bd%aesuabase%e5%ae%a2%e6%88%b7%e7%ab%af" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h3><p>首先创建一个<code>db.ts</code>文件，并实例化 <code>supabaseClient</code>。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="51ad8c3" class="language-ts ">
  <code>import { createClient } from &#39;@supabase/auth-helpers-sveltekit&#39;
import { env } from &#39;$env/dynamic/public&#39;
// or use the static env
// import { PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY } from &#39;$env/static/public&#39;;

export const supabaseClient = createClient(env.PUBLIC_SUPABASE_URL, env.PUBLIC_SUPABASE_ANON_KEY)</code>
  </pre>
  </div>
<p>要确保在服务器和客户端上初始化了客户端，请在<code>src/hooks.server.js</code>中包含此文件。js<code>和</code>src/hooks.client.js`：</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="d312cd5" class="language-ts ">
  <code>import &#39;$lib/db&#39;</code>
  </pre>
  </div>
<h3 id="同步页面存储">同步页面存储 <a href="#%e5%90%8c%e6%ad%a5%e9%a1%b5%e9%9d%a2%e5%ad%98%e5%82%a8" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h3><p>编辑<code>+layout.svelte</code>文件并设置客户端。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="0a5e583" class="language-html ">
  <code>&lt;script&gt;
  import { supabaseClient } from &#39;$lib/db&#39;
  import { invalidate } from &#39;$app/navigation&#39;
  import { onMount } from &#39;svelte&#39;

  onMount(() =&gt; {
    const {
      data: { subscription },
    } = supabaseClient.auth.onAuthStateChange(() =&gt; {
      invalidate(&#39;supabase:auth&#39;)
    })

    return () =&gt; {
      subscription.unsubscribe()
    }
  })
&lt;/script&gt;

&lt;slot /&gt;</code>
  </pre>
  </div>
<p>调用 <code>invalidate('supabase:auth')</code>时，使用<code>getSupabase()</code> 的每个<code>PageLoad</code>或 <code>LayoutLoad</code>都将更新。</p>
<p>如果某些数据在登录/注销时未更新，则可以返回到 <code>invalidateAll()</code>。</p>
<h3 id="向客户端发送会话">向客户端发送会话 <a href="#%e5%90%91%e5%ae%a2%e6%88%b7%e7%ab%af%e5%8f%91%e9%80%81%e4%bc%9a%e8%af%9d" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h3><p>要使会话对UI（页面、布局）可用，请在根布局服务器加载函数中传递会话：</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="bcacc34" class="language-ts ">
  <code>import type { LayoutServerLoad } from &#39;./$types&#39;
import { getServerSession } from &#39;@supabase/auth-helpers-sveltekit&#39;

export const load: LayoutServerLoad = async (event) =&gt; {
  return {
    session: await getServerSession(event),
  }
}</code>
  </pre>
  </div>
<p>此外，如果使用<code>invalidate('supabase:auth')</code>，则可以创建布局加载函数：</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="9f07619" class="language-ts ">
  <code>import type { LayoutLoad } from &#39;./$types&#39;
import { getSupabase } from &#39;@supabase/auth-helpers-sveltekit&#39;

export const load: LayoutLoad = async (event) =&gt; {
  const { session } = await getSupabase(event)
  return { session }
}</code>
  </pre>
  </div>
<p>这会减少服务器调用，因为客户端自己管理会话。</p>
<h3 id="键入">键入 <a href="#%e9%94%ae%e5%85%a5" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h3><p>为了充分利用TypeScript及其智能感知，您应该将我们的类型导入到SveltKit项目附带的<code>app.d.ts</code>类型定义文件中。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="bf1b965" class="language-ts ">
  <code>/// &lt;reference types=&#34;@sveltejs/kit&#34; /&gt;

// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
// and what to do when importing types
declare namespace App {
  interface Supabase {
    Database: import(&#39;./DatabaseDefinitions&#39;).Database
    SchemaName: &#39;public&#39;
  }

  // interface Locals {}
  interface PageData {
    session: import(&#39;@supabase/supabase-js&#39;).Session | null
  }
  // interface Error {}
  // interface Platform {}
}</code>
  </pre>
  </div>
<h3 id="基本设置">基本设置 <a href="#%e5%9f%ba%e6%9c%ac%e8%ae%be%e7%bd%ae" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h3><p>现在，您可以通过检查 <code>$page.data</code>中的<code>session</code>对象来确定用户是否在客户端进行了身份验证。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="e50cbb0" class="language-html ">
  <code>&lt;script&gt;
  import { page } from &#39;$app/stores&#39;
&lt;/script&gt;

{#if !$page.data.session}
&lt;h1&gt;I am not logged in&lt;/h1&gt;
{:else}
&lt;h1&gt;Welcome {$page.data.session.user.email}&lt;/h1&gt;
&lt;p&gt;I am logged in!&lt;/p&gt;
{/if}</code>
  </pre>
  </div>
<h2 id="使用rls获取客户端数据">使用RLS获取客户端数据 <a href="#%e4%bd%bf%e7%94%a8rls%e8%8e%b7%e5%8f%96%e5%ae%a2%e6%88%b7%e7%ab%af%e6%95%b0%e6%8d%ae" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p>为了使<a href="../../../../../learn/auth-deep-dive/auth-row-level-security.html">行级别安全</a>在客户端获取数据时正常工作，您需要确保从 <code>$lib/db</code>导入 <code>{ supabaseClient }</code>，并仅在 <code>$page.data</code>中定义了客户端会话后才运行查询：</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="13e5415" class="language-html ">
  <code>&lt;script&gt;
  import { supabaseClient } from &#39;$lib/db&#39;
  import { page } from &#39;$app/stores&#39;

  let loadedData = []
  async function loadData() {
    const { data } = await supabaseClient.from(&#39;test&#39;).select(&#39;*&#39;).limit(20)
    loadedData = data
  }

  $: if ($page.data.session) {
    loadData()
  }
&lt;/script&gt;

{#if $page.data.session}
&lt;p&gt;client-side data fetching with RLS&lt;/p&gt;
&lt;pre&gt;{JSON.stringify(loadedData, null, 2)}&lt;/pre&gt;
{/if}</code>
  </pre>
  </div>
<h2 id="使用rls获取服务器端数据">使用RLS获取服务器端数据 <a href="#%e4%bd%bf%e7%94%a8rls%e8%8e%b7%e5%8f%96%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%ab%af%e6%95%b0%e6%8d%ae" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2>


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="27e19a4" class="language-html ">
  <code>&lt;script&gt;
  /** @type {import(&#39;./$types&#39;).PageData} */
  export let data
  $: ({ user, tableData } = data)
&lt;/script&gt;

&lt;div&gt;Protected content for {user.email}&lt;/div&gt;
&lt;pre&gt;{JSON.stringify(tableData, null, 2)}&lt;/pre&gt;
&lt;pre&gt;{JSON.stringify(user, null, 2)}&lt;/pre&gt;</code>
  </pre>
  </div>
<p>要使<a href="../../../../../learn/auth-deep-dive/auth-row-level-security.html">row-level security</a>在服务器环境中工作，您需要使用 <code>getSupabase</code>帮助器来检查用户是否经过身份验证。助手需要 <code>event</code> 并返回 <code>session</code> 和 <code>supabaseClient</code>：</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="5471167" class="language-ts ">
  <code>import type { PageLoad } from &#39;./$types&#39;
import { getSupabase } from &#39;@supabase/auth-helpers-sveltekit&#39;
import { redirect } from &#39;@sveltejs/kit&#39;

export const load: PageLoad = async (event) =&gt; {
  const { session, supabaseClient } = await getSupabase(event)
  if (!session) {
    throw redirect(303, &#39;/&#39;)
  }
  const { data: tableData } = await supabaseClient.from(&#39;test&#39;).select(&#39;*&#39;)

  return {
    user: session.user,
    tableData,
  }
}</code>
  </pre>
  </div>
<h2 id="保护api路由">保护API路由 <a href="#%e4%bf%9d%e6%8a%a4api%e8%b7%af%e7%94%b1" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p>包装API路由以检查用户是否具有有效会话。如果他们未登录，则会话为 <code>null</code>。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="68eca24" class="language-ts ">
  <code>import type { RequestHandler } from &#39;./$types&#39;
import { getSupabase } from &#39;@supabase/auth-helpers-sveltekit&#39;
import { json, redirect } from &#39;@sveltejs/kit&#39;

export const GET: RequestHandler = async (event) =&gt; {
  const { session, supabaseClient } = await getSupabase(event)
  if (!session) {
    throw redirect(303, &#39;/&#39;)
  }
  const { data } = await supabaseClient.from(&#39;test&#39;).select(&#39;*&#39;)

  return json({ data })
}</code>
  </pre>
  </div>
<p>如果您在没有有效会话cookie的情况下访问<code>/api/protected-route</code>，将得到303响应。</p>
<h2 id="保护措施">保护措施 <a href="#%e4%bf%9d%e6%8a%a4%e6%8e%aa%e6%96%bd" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p>包装操作以检查用户是否具有有效会话。如果他们未登录，则会话为 <code>null</code>。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="3fb11e8" class="language-ts ">
  <code>import type { Actions } from &#39;./$types&#39;
import { getSupabase } from &#39;@supabase/auth-helpers-sveltekit&#39;
import { error, invalid } from &#39;@sveltejs/kit&#39;

export const actions: Actions = {
  createPost: async (event) =&gt; {
    const { request } = event
    const { session, supabaseClient } = await getSupabase(event)
    if (!session) {
      // the user is not signed in
      throw error(403, { message: &#39;Unauthorized&#39; })
    }
    // we are save, let the user create the post
    const formData = await request.formData()
    const content = formData.get(&#39;content&#39;)

    const { error: createPostError, data: newPost } = await supabaseClient
      .from(&#39;posts&#39;)
      .insert({ content })

    if (createPostError) {
      return invalid(500, {
        supabaseErrorMessage: createPostError.message,
      })
    }
    return {
      newPost,
    }
  },
}</code>
  </pre>
  </div>
<p>如果您尝试提交带有操作的表单 <code>?/createPost</code>如果没有有效的会话cookie，您将得到403错误响应。</p>
<h2 id="保存和删除会话">保存和删除会话 <a href="#%e4%bf%9d%e5%ad%98%e5%92%8c%e5%88%a0%e9%99%a4%e4%bc%9a%e8%af%9d" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2>


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="6a51920" class="language-ts ">
  <code>import type { Actions } from &#39;./$types&#39;
import { invalid, redirect } from &#39;@sveltejs/kit&#39;
import { getSupabase } from &#39;@supabase/auth-helpers-sveltekit&#39;

export const actions: Actions = {
  signin: async (event) =&gt; {
    const { request, cookies, url } = event
    const { session, supabaseClient } = await getSupabase(event)
    const formData = await request.formData()

    const email = formData.get(&#39;email&#39;) as string
    const password = formData.get(&#39;password&#39;) as string

    const { error } = await supabaseClient.auth.signInWithPassword({
      email,
      password,
    })

    if (error) {
      if (error instanceof AuthApiError &amp;&amp; error.status === 400) {
        return invalid(400, {
          error: &#39;Invalid credentials.&#39;,
          values: {
            email,
          },
        })
      }
      return invalid(500, {
        error: &#39;Server error. Try again later.&#39;,
        values: {
          email,
        },
      })
    }

    throw redirect(303, &#39;/dashboard&#39;)
  },

  signout: async (event) =&gt; {
    const { supabaseClient } = await getSupabase(event)
    await supabaseClient.auth.signOut()
    throw redirect(303, &#39;/&#39;)
  },
}</code>
  </pre>
  </div>
<h2 id="保护多条路线">保护多条路线 <a href="#%e4%bf%9d%e6%8a%a4%e5%a4%9a%e6%9d%a1%e8%b7%af%e7%ba%bf" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p>为了避免在每条路由中写入相同的身份验证逻辑，可以使用句柄钩子同时保护多条路由。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="b592020" class="language-ts ">
  <code>import type { RequestHandler } from &#39;./$types&#39;
import { getSupabase } from &#39;@supabase/auth-helpers-sveltekit&#39;
import { redirect, error } from &#39;@sveltejs/kit&#39;

export const handle: Handle = async ({ event, resolve }) =&gt; {
  // protect requests to all routes that start with /protected-routes
  if (event.url.pathname.startsWith(&#39;/protected-routes&#39;)) {
    const { session, supabaseClient } = await getSupabase(event)

    if (!session) {
      throw redirect(303, &#39;/&#39;)
    }
  }

  // protect POST requests to all routes that start with /protected-posts
  if (event.url.pathname.startsWith(&#39;/protected-posts&#39;) &amp;&amp; event.request.method === &#39;POST&#39;) {
    const { session, supabaseClient } = await getSupabase(event)

    if (!session) {
      throw error(303, &#39;/&#39;)
    }
  }

  return resolve(event)
}</code>
  </pre>
  </div>
<h2 id="migration">从0.7.x迁移到0.8 <a href="#migration" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><h3 id="migration-set-up-supabase-client">设置Supabase客户端 <a href="#migration-set-up-supabase-client" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h3>
<nav>
	<div class="nav nav-tabs" id="nav-tab" role="tablist">

		
		
		
		

		

		<a class="nav-link  active"
		   id="fdebcaTab" data-bs-toggle="tab" data-bs-target="#fdebca"
		   type="button" role="tab" aria-controls="fdebca" aria-selected="true">0.7.x</a>

		

		<a class="nav-link "
		   id="afdbecTab" data-bs-toggle="tab" data-bs-target="#afdbec"
		   type="button" role="tab" aria-controls="afdbec" aria-selected="true">0.8.0</a>

		

	</div>
</nav>

<div class="tab-content" id="nav-tab-content">

	






<div class="tab-pane fade show active" id="fdebca" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="5b03eec" class="language-js ">
  <code>import { createClient } from &#39;@supabase/supabase-js&#39;
import { setupSupabaseHelpers } from &#39;@supabase/auth-helpers-sveltekit&#39;
import { dev } from &#39;$app/environment&#39;
import { env } from &#39;$env/dynamic/public&#39;
// or use the static env

// import { PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY } from &#39;$env/static/public&#39;;

export const supabaseClient = createClient(env.PUBLIC_SUPABASE_URL, env.PUBLIC_SUPABASE_ANON_KEY, {
  persistSession: false,
  autoRefreshToken: false,
})

setupSupabaseHelpers({
  supabaseClient,
  cookieOptions: {
    secure: !dev,
  },
})</code>
  </pre>
  </div>


</div>






<div class="tab-pane fade" id="afdbec" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="46a9076" class="language-js ">
  <code>import { createClient } from &#39;@supabase/auth-helpers-sveltekit&#39;
import { env } from &#39;$env/dynamic/public&#39;
// or use the static env

// import { PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY } from &#39;$env/static/public&#39;;

export const supabaseClient = createClient(env.PUBLIC_SUPABASE_URL, env.PUBLIC_SUPABASE_ANON_KEY)</code>
  </pre>
  </div>


</div>


</div>
<h3 id="migration-initialize-client">初始化客户端 <a href="#migration-initialize-client" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h3>
<nav>
	<div class="nav nav-tabs" id="nav-tab" role="tablist">

		
		
		
		

		

		<a class="nav-link  active"
		   id="abedfcTab" data-bs-toggle="tab" data-bs-target="#abedfc"
		   type="button" role="tab" aria-controls="abedfc" aria-selected="true">0.7.x</a>

		

		<a class="nav-link "
		   id="bdeafcTab" data-bs-toggle="tab" data-bs-target="#bdeafc"
		   type="button" role="tab" aria-controls="bdeafc" aria-selected="true">0.8.0</a>

		

	</div>
</nav>

<div class="tab-content" id="nav-tab-content">

	






<div class="tab-pane fade show active" id="abedfc" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="8ea8db4" class="language-html ">
  <code>&lt;script lang=&#34;ts&#34;&gt;
  // make sure the supabase instance is initialized on the client
  import &#39;$lib/db&#39;
  import { startSupabaseSessionSync } from &#39;@supabase/auth-helpers-sveltekit&#39;
  import { page } from &#39;$app/stores&#39;
  import { invalidateAll } from &#39;$app/navigation&#39;

  // this sets up automatic token refreshing
  startSupabaseSessionSync({
    page,
    handleRefresh: () =&gt; invalidateAll(),
  })
&lt;/script&gt;

&lt;slot /&gt;</code>
  </pre>
  </div>


</div>






<div class="tab-pane fade" id="bdeafc" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="31ca36e" class="language-html ">
  <code>&lt;script&gt;
  import { supabaseClient } from &#39;$lib/db&#39;
  import { invalidate } from &#39;$app/navigation&#39;
  import { onMount } from &#39;svelte&#39;

  onMount(() =&gt; {
    const {
      data: { subscription },
    } = supabaseClient.auth.onAuthStateChange(() =&gt; {
      invalidate(&#39;supabase:auth&#39;)
    })

    return () =&gt; {
      subscription.unsubscribe()
    }
  })
&lt;/script&gt;

&lt;slot /&gt;</code>
  </pre>
  </div>


</div>


</div>
<h3 id="migration-set-up-hooks">设置挂钩 <a href="#migration-set-up-hooks" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h3>
<nav>
	<div class="nav nav-tabs" id="nav-tab" role="tablist">

		
		
		
		

		

		<a class="nav-link  active"
		   id="bdcfaeTab" data-bs-toggle="tab" data-bs-target="#bdcfae"
		   type="button" role="tab" aria-controls="bdcfae" aria-selected="true">0.7.x</a>

		

		<a class="nav-link "
		   id="acedbfTab" data-bs-toggle="tab" data-bs-target="#acedbf"
		   type="button" role="tab" aria-controls="acedbf" aria-selected="true">0.8.0</a>

		

	</div>
</nav>

<div class="tab-content" id="nav-tab-content">

	






<div class="tab-pane fade show active" id="bdcfae" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="2c62bab" class="language-ts ">
  <code>// make sure the supabase instance is initialized on the server
import &#39;$lib/db&#39;
import { dev } from &#39;$app/environment&#39;
import { auth } from &#39;@supabase/auth-helpers-sveltekit/server&#39;

export const handle = auth()</code>
  </pre>
  </div>
<p><strong>使用其他句柄方法的可选</strong><em>if</em></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="76b1059" class="language-ts ">
  <code>// make sure the supabase instance is initialized on the server
import &#39;$lib/db&#39;
import { dev } from &#39;$app/environment&#39;
import { auth } from &#39;@supabase/auth-helpers-sveltekit/server&#39;
import { sequence } from &#39;@sveltejs/kit/hooks&#39;

export const handle = sequence(auth(), yourHandler)</code>
  </pre>
  </div>


</div>






<div class="tab-pane fade" id="acedbf" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="97fbb8b" class="language-ts ">
  <code>// make sure the supabase instance is initialized on the server
import &#39;$lib/db&#39;</code>
  </pre>
  </div>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="415838a" class="language-ts ">
  <code>// make sure the supabase instance is initialized on the client
import &#39;$lib/db&#39;</code>
  </pre>
  </div>


</div>


</div>
<h3 id="migration-typings">键入 <a href="#migration-typings" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h3>
<nav>
	<div class="nav nav-tabs" id="nav-tab" role="tablist">

		
		
		
		

		

		<a class="nav-link  active"
		   id="dbcafeTab" data-bs-toggle="tab" data-bs-target="#dbcafe"
		   type="button" role="tab" aria-controls="dbcafe" aria-selected="true">0.7.x</a>

		

		<a class="nav-link "
		   id="bfeadcTab" data-bs-toggle="tab" data-bs-target="#bfeadc"
		   type="button" role="tab" aria-controls="bfeadc" aria-selected="true">0.8.0</a>

		

	</div>
</nav>

<div class="tab-content" id="nav-tab-content">

	







<div class="tab-pane fade show active" id="dbcafe" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="81ef842" class="language-ts ">
  <code>/// &lt;reference types=&#34;@sveltejs/kit&#34; /&gt;

// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
// and what to do when importing types
declare namespace App {
  interface Locals {
    session: import(&#39;@supabase/auth-helpers-sveltekit&#39;).SupabaseSession
  }

  interface PageData {
    session: import(&#39;@supabase/auth-helpers-sveltekit&#39;).SupabaseSession
  }

  // interface Error {}
  // interface Platform {}
}</code>
  </pre>
  </div>


</div>






<div class="tab-pane fade" id="bfeadc" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="c196d38" class="language-ts ">
  <code>/// &lt;reference types=&#34;@sveltejs/kit&#34; /&gt;

// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
// and what to do when importing types
declare namespace App {
  interface Supabase {
    Database: import(&#39;./DatabaseDefinitions&#39;).Database
    SchemaName: &#39;public&#39;
  }

  // interface Locals {}
  interface PageData {
    session: import(&#39;@supabase/auth-helpers-sveltekit&#39;).SupabaseSession
  }
  // interface Error {}
  // interface Platform {}
}</code>
  </pre>
  </div>


</div>


</div>
<h3 id="migration-with-page-auth">withPageAuth <a href="#migration-with-page-auth" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h3>
<nav>
	<div class="nav nav-tabs" id="nav-tab" role="tablist">

		
		
		
		

		

		<a class="nav-link  active"
		   id="cbdfeaTab" data-bs-toggle="tab" data-bs-target="#cbdfea"
		   type="button" role="tab" aria-controls="cbdfea" aria-selected="true">0.7.x</a>

		

		<a class="nav-link "
		   id="fabdceTab" data-bs-toggle="tab" data-bs-target="#fabdce"
		   type="button" role="tab" aria-controls="fabdce" aria-selected="true">0.8.0</a>

		

	</div>
</nav>

<div class="tab-content" id="nav-tab-content">

	






<div class="tab-pane fade show active" id="cbdfea" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="b405a11" class="language-html ">
  <code>&lt;script lang=&#34;ts&#34;&gt;
  import type { PageData } from &#39;./$types&#39;

  export let data: PageData
  $: ({ tableData, user } = data)
&lt;/script&gt;

&lt;div&gt;Protected content for {user.email}&lt;/div&gt;
&lt;p&gt;server-side fetched data with RLS:&lt;/p&gt;
&lt;pre&gt;{JSON.stringify(tableData, null, 2)}&lt;/pre&gt;
&lt;p&gt;user:&lt;/p&gt;
&lt;pre&gt;{JSON.stringify(user, null, 2)}&lt;/pre&gt;</code>
  </pre>
  </div>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="e4e4ad1" class="language-ts ">
  <code>import { withAuth } from &#39;@supabase/auth-helpers-sveltekit&#39;
import { redirect } from &#39;@sveltejs/kit&#39;
import type { PageLoad } from &#39;./$types&#39;

export const load: PageLoad = withAuth(async ({ session, getSupabaseClient }) =&gt; {
  if (!session.user) {
    throw redirect(303, &#39;/&#39;)
  }

  const { data: tableData } = await getSupabaseClient().from(&#39;test&#39;).select(&#39;*&#39;)
  return { tableData, user: session.user }
})</code>
  </pre>
  </div>


</div>






<div class="tab-pane fade" id="fabdce" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="eb6be29" class="language-html ">
  <code>&lt;script&gt;
  /** @type {import(&#39;./$types&#39;).PageData} */
  export let data
  $: ({ user, tableData } = data)
&lt;/script&gt;

&lt;div&gt;Protected content for {user.email}&lt;/div&gt;
&lt;pre&gt;{JSON.stringify(tableData, null, 2)}&lt;/pre&gt;
&lt;pre&gt;{JSON.stringify(user, null, 2)}&lt;/pre&gt;</code>
  </pre>
  </div>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="d1c9a84" class="language-ts ">
  <code>// src/routes/profile/&#43;page.ts
import type { PageLoad } from &#39;./$types&#39;
import { getSupabase } from &#39;@supabase/auth-helpers-sveltekit&#39;
import { redirect } from &#39;@sveltejs/kit&#39;

export const load: PageLoad = async (event) =&gt; {
  const { session, supabaseClient } = await getSupabase(event)
  if (!session) {
    throw redirect(303, &#39;/&#39;)
  }
  const { data: tableData } = await supabaseClient.from(&#39;test&#39;).select(&#39;*&#39;)

  return {
    user: session.user,
    tableData,
  }
}</code>
  </pre>
  </div>


</div>


</div>
<h3 id="migration-with-api-auth">withApiAuth <a href="#migration-with-api-auth" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h3>
<nav>
	<div class="nav nav-tabs" id="nav-tab" role="tablist">

		
		
		
		

		

		<a class="nav-link  active"
		   id="deafcbTab" data-bs-toggle="tab" data-bs-target="#deafcb"
		   type="button" role="tab" aria-controls="deafcb" aria-selected="true">0.7.x</a>

		

		<a class="nav-link "
		   id="cabefdTab" data-bs-toggle="tab" data-bs-target="#cabefd"
		   type="button" role="tab" aria-controls="cabefd" aria-selected="true">0.8.0</a>

		

	</div>
</nav>

<div class="tab-content" id="nav-tab-content">

	






<div class="tab-pane fade show active" id="deafcb" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="1bbdf07" class="language-ts ">
  <code>import type { RequestHandler } from &#39;./$types&#39;
import { withAuth } from &#39;@supabase/auth-helpers-sveltekit&#39;
import { json, redirect } from &#39;@sveltejs/kit&#39;

interface TestTable {
  id: string
  created_at: string
}

export const GET: RequestHandler = withAuth(async ({ session, getSupabaseClient }) =&gt; {
  if (!session.user) {
    throw redirect(303, &#39;/&#39;)
  }

  const { data } = await getSupabaseClient().from&lt;TestTable&gt;(&#39;test&#39;).select(&#39;*&#39;)

  return json({ data })
})</code>
  </pre>
  </div>


</div>






<div class="tab-pane fade" id="cabefd" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="5e5f2b6" class="language-ts ">
  <code>import type { RequestHandler } from &#39;./$types&#39;
import { getSupabase } from &#39;@supabase/auth-helpers-sveltekit&#39;
import { json, redirect } from &#39;@sveltejs/kit&#39;

export const GET: RequestHandler = async (event) =&gt; {
  const { session, supabaseClient } = await getSupabase(event)
  if (!session) {
    throw redirect(303, &#39;/&#39;)
  }
  const { data } = await supabaseClient.from(&#39;test&#39;).select(&#39;*&#39;)

  return json({ data })
}</code>
  </pre>
  </div>


</div>


</div>
<h2 id="migration-0-7">从0.6.11及以下迁移到0.7.0 <a href="#migration-0-7" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p>此库的最新0.7.0版本中有许多突破性的更改。</p>
<h3 id="环境变量前缀">环境变量前缀 <a href="#%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f%e5%89%8d%e7%bc%80" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h3><p>环境变量前缀现在是<code>PUBLIC_</code>而不是<code>VITE_</code>（例如，<code>VITE_SUPABASE_URL</code>现在是<code>BUBLIC_SUPABASE_URL</code>）。</p>
<h3 id="migration-set-up-supabase-client-0-7">设置Supabase客户端 <a href="#migration-set-up-supabase-client-0-7" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h3>
<nav>
	<div class="nav nav-tabs" id="nav-tab" role="tablist">

		
		
		
		

		

		<a class="nav-link  active"
		   id="fdeabcTab" data-bs-toggle="tab" data-bs-target="#fdeabc"
		   type="button" role="tab" aria-controls="fdeabc" aria-selected="true">0.6.11 and below</a>

		

		<a class="nav-link "
		   id="dbcaefTab" data-bs-toggle="tab" data-bs-target="#dbcaef"
		   type="button" role="tab" aria-controls="dbcaef" aria-selected="true">0.7.0</a>

		

	</div>
</nav>

<div class="tab-content" id="nav-tab-content">

	






<div class="tab-pane fade show active" id="fdeabc" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="a1df91f" class="language-js ">
  <code>import { createSupabaseClient } from &#39;@supabase/auth-helpers-sveltekit&#39;;

const { supabaseClient } = createSupabaseClient(
  import.meta.env.VITE_SUPABASE_URL as string,
  import.meta.env.VITE_SUPABASE_ANON_KEY as string
);

export { supabaseClient };</code>
  </pre>
  </div>


</div>






<div class="tab-pane fade" id="dbcaef" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="5b03eec" class="language-js ">
  <code>import { createClient } from &#39;@supabase/supabase-js&#39;
import { setupSupabaseHelpers } from &#39;@supabase/auth-helpers-sveltekit&#39;
import { dev } from &#39;$app/environment&#39;
import { env } from &#39;$env/dynamic/public&#39;
// or use the static env

// import { PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY } from &#39;$env/static/public&#39;;

export const supabaseClient = createClient(env.PUBLIC_SUPABASE_URL, env.PUBLIC_SUPABASE_ANON_KEY, {
  persistSession: false,
  autoRefreshToken: false,
})

setupSupabaseHelpers({
  supabaseClient,
  cookieOptions: {
    secure: !dev,
  },
})</code>
  </pre>
  </div>


</div>


</div>
<h3 id="migration-initialize-client-0-7">初始化客户端 <a href="#migration-initialize-client-0-7" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h3>
<nav>
	<div class="nav nav-tabs" id="nav-tab" role="tablist">

		
		
		
		

		

		<a class="nav-link  active"
		   id="dcafbeTab" data-bs-toggle="tab" data-bs-target="#dcafbe"
		   type="button" role="tab" aria-controls="dcafbe" aria-selected="true">0.6.11 and below</a>

		

		<a class="nav-link "
		   id="dbecafTab" data-bs-toggle="tab" data-bs-target="#dbecaf"
		   type="button" role="tab" aria-controls="dbecaf" aria-selected="true">0.7.0</a>

		

	</div>
</nav>

<div class="tab-content" id="nav-tab-content">

	






<div class="tab-pane fade show active" id="dcafbe" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="9857471" class="language-html ">
  <code>&lt;script&gt;
  import { session } from &#39;$app/stores&#39;
  import { supabaseClient } from &#39;$lib/db&#39;
  import { SupaAuthHelper } from &#39;@supabase/auth-helpers-svelte&#39;
&lt;/script&gt;

&lt;SupaAuthHelper {supabaseClient} {session}&gt;
  &lt;slot /&gt;
&lt;/SupaAuthHelper&gt;</code>
  </pre>
  </div>


</div>






<div class="tab-pane fade" id="dbecaf" role="tabpanel" aria-labelledby="nav-1">

	<p>不再需要<code>@supabase/auth-helpers-svelte</code>库，因为 <code>@supabase/auth-helpers-sveltekit</code> 库处理所有客户端代码。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="8ea8db4" class="language-html ">
  <code>&lt;script lang=&#34;ts&#34;&gt;
  // make sure the supabase instance is initialized on the client
  import &#39;$lib/db&#39;
  import { startSupabaseSessionSync } from &#39;@supabase/auth-helpers-sveltekit&#39;
  import { page } from &#39;$app/stores&#39;
  import { invalidateAll } from &#39;$app/navigation&#39;

  // this sets up automatic token refreshing
  startSupabaseSessionSync({
    page,
    handleRefresh: () =&gt; invalidateAll(),
  })
&lt;/script&gt;

&lt;slot /&gt;</code>
  </pre>
  </div>


</div>


</div>
<h3 id="migration-set-up-hooks-0-7">设置挂钩 <a href="#migration-set-up-hooks-0-7" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h3>
<nav>
	<div class="nav nav-tabs" id="nav-tab" role="tablist">

		
		
		
		

		

		<a class="nav-link  active"
		   id="afcedbTab" data-bs-toggle="tab" data-bs-target="#afcedb"
		   type="button" role="tab" aria-controls="afcedb" aria-selected="true">0.6.11 and below</a>

		

		<a class="nav-link "
		   id="fabcdeTab" data-bs-toggle="tab" data-bs-target="#fabcde"
		   type="button" role="tab" aria-controls="fabcde" aria-selected="true">0.7.0</a>

		

	</div>
</nav>

<div class="tab-content" id="nav-tab-content">

	






<div class="tab-pane fade show active" id="afcedb" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="2a7516e" class="language-ts ">
  <code>import { handleAuth } from &#39;@supabase/auth-helpers-sveltekit&#39;
import type { GetSession, Handle } from &#39;@sveltejs/kit&#39;
import { sequence } from &#39;@sveltejs/kit/hooks&#39;

export const handle: Handle = sequence(...handleAuth())

export const getSession: GetSession = async (event) =&gt; {
  const { user, accessToken, error } = event.locals
  return {
    user,
    accessToken,
    error,
  }
}</code>
  </pre>
  </div>


</div>






<div class="tab-pane fade" id="fabcde" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="2c62bab" class="language-ts ">
  <code>// make sure the supabase instance is initialized on the server
import &#39;$lib/db&#39;
import { dev } from &#39;$app/environment&#39;
import { auth } from &#39;@supabase/auth-helpers-sveltekit/server&#39;

export const handle = auth()</code>
  </pre>
  </div>
<p><strong>使用其他句柄方法的可选</strong><em>if</em></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="76b1059" class="language-ts ">
  <code>// make sure the supabase instance is initialized on the server
import &#39;$lib/db&#39;
import { dev } from &#39;$app/environment&#39;
import { auth } from &#39;@supabase/auth-helpers-sveltekit/server&#39;
import { sequence } from &#39;@sveltejs/kit/hooks&#39;

export const handle = sequence(auth(), yourHandler)</code>
  </pre>
  </div>


</div>


</div>
<h3 id="migration-typings-0-7">键入 <a href="#migration-typings-0-7" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h3>
<nav>
	<div class="nav nav-tabs" id="nav-tab" role="tablist">

		
		
		
		

		

		<a class="nav-link  active"
		   id="cfaedbTab" data-bs-toggle="tab" data-bs-target="#cfaedb"
		   type="button" role="tab" aria-controls="cfaedb" aria-selected="true">0.6.11 and below</a>

		

		<a class="nav-link "
		   id="eafdbcTab" data-bs-toggle="tab" data-bs-target="#eafdbc"
		   type="button" role="tab" aria-controls="eafdbc" aria-selected="true">0.7.0</a>

		

	</div>
</nav>

<div class="tab-content" id="nav-tab-content">

	






<div class="tab-pane fade show active" id="cfaedb" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="2ac0573" class="language-ts ">
  <code>/// &lt;reference types=&#34;@sveltejs/kit&#34; /&gt;
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare namespace App {
  interface UserSession {
    user: import(&#39;@supabase/supabase-js&#39;).User
    accessToken?: string
  }

  interface Locals extends UserSession {
    error: import(&#39;@supabase/supabase-js&#39;).ApiError
  }

  interface Session extends UserSession {}

  // interface Platform {}
  // interface Stuff {}
}</code>
  </pre>
  </div>


</div>






<div class="tab-pane fade" id="eafdbc" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="81ef842" class="language-ts ">
  <code>/// &lt;reference types=&#34;@sveltejs/kit&#34; /&gt;

// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
// and what to do when importing types
declare namespace App {
  interface Locals {
    session: import(&#39;@supabase/auth-helpers-sveltekit&#39;).SupabaseSession
  }

  interface PageData {
    session: import(&#39;@supabase/auth-helpers-sveltekit&#39;).SupabaseSession
  }

  // interface Error {}
  // interface Platform {}
}</code>
  </pre>
  </div>


</div>


</div>
<h3 id="检查客户端上的用户">检查客户端上的用户 <a href="#%e6%a3%80%e6%9f%a5%e5%ae%a2%e6%88%b7%e7%ab%af%e4%b8%8a%e7%9a%84%e7%94%a8%e6%88%b7" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h3>
<nav>
	<div class="nav nav-tabs" id="nav-tab" role="tablist">

		
		
		
		

		

		<a class="nav-link  active"
		   id="abfecdTab" data-bs-toggle="tab" data-bs-target="#abfecd"
		   type="button" role="tab" aria-controls="abfecd" aria-selected="true">0.6.11 and below</a>

		

		<a class="nav-link "
		   id="dbacefTab" data-bs-toggle="tab" data-bs-target="#dbacef"
		   type="button" role="tab" aria-controls="dbacef" aria-selected="true">0.7.0</a>

		

	</div>
</nav>

<div class="tab-content" id="nav-tab-content">

	






<div class="tab-pane fade show active" id="abfecd" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="dbaea94" class="language-html ">
  <code>&lt;script&gt;
  import { session } from &#39;$app/stores&#39;
&lt;/script&gt;

{#if !$session.user}
&lt;h1&gt;I am not logged in&lt;/h1&gt;
{:else}
&lt;h1&gt;Welcome {$session.user.email}&lt;/h1&gt;
&lt;p&gt;I am logged in!&lt;/p&gt;
{/if}</code>
  </pre>
  </div>


</div>






<div class="tab-pane fade" id="dbacef" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="48231ae" class="language-html ">
  <code>&lt;script&gt;
  import { page } from &#39;$app/stores&#39;
&lt;/script&gt;

{#if !$page.data.session.user}
&lt;h1&gt;I am not logged in&lt;/h1&gt;
{:else}
&lt;h1&gt;Welcome {$page.data.session.user.email}&lt;/h1&gt;
&lt;p&gt;I am logged in!&lt;/p&gt;
{/if}</code>
  </pre>
  </div>


</div>


</div>
<h3 id="withpageauth">withPageAuth <a href="#withpageauth" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h3>
<nav>
	<div class="nav nav-tabs" id="nav-tab" role="tablist">

		
		
		
		

		

		<a class="nav-link  active"
		   id="eacbdfTab" data-bs-toggle="tab" data-bs-target="#eacbdf"
		   type="button" role="tab" aria-controls="eacbdf" aria-selected="true">0.6.11 and below</a>

		

		<a class="nav-link "
		   id="bedafcTab" data-bs-toggle="tab" data-bs-target="#bedafc"
		   type="button" role="tab" aria-controls="bedafc" aria-selected="true">0.7.0</a>

		

	</div>
</nav>

<div class="tab-content" id="nav-tab-content">

	






<div class="tab-pane fade show active" id="eacbdf" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="eee2664" class="language-html ">
  <code>&lt;script lang=&#34;ts&#34; context=&#34;module&#34;&gt;
  import { supabaseServerClient, withPageAuth } from &#39;@supabase/auth-helpers-sveltekit&#39;
  import type { Load } from &#39;./__types/protected-page&#39;

  export const load: Load = async ({ session }) =&gt;
    withPageAuth(
      {
        redirectTo: &#39;/&#39;,
        user: session.user,
      },
      async () =&gt; {
        const { data } = await supabaseServerClient(session.accessToken).from(&#39;test&#39;).select(&#39;*&#39;)
        return { props: { data, user: session.user } }
      }
    )
&lt;/script&gt;

&lt;script&gt;
  export let data
  export let user
&lt;/script&gt;

&lt;div&gt;Protected content for {user.email}&lt;/div&gt;
&lt;p&gt;server-side fetched data with RLS:&lt;/p&gt;
&lt;pre&gt;{JSON.stringify(data, null, 2)}&lt;/pre&gt;
&lt;p&gt;user:&lt;/p&gt;
&lt;pre&gt;{JSON.stringify(user, null, 2)}&lt;/pre&gt;</code>
  </pre>
  </div>


</div>






<div class="tab-pane fade" id="bedafc" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="b405a11" class="language-html ">
  <code>&lt;script lang=&#34;ts&#34;&gt;
  import type { PageData } from &#39;./$types&#39;

  export let data: PageData
  $: ({ tableData, user } = data)
&lt;/script&gt;

&lt;div&gt;Protected content for {user.email}&lt;/div&gt;
&lt;p&gt;server-side fetched data with RLS:&lt;/p&gt;
&lt;pre&gt;{JSON.stringify(tableData, null, 2)}&lt;/pre&gt;
&lt;p&gt;user:&lt;/p&gt;
&lt;pre&gt;{JSON.stringify(user, null, 2)}&lt;/pre&gt;</code>
  </pre>
  </div>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="e4e4ad1" class="language-ts ">
  <code>import { withAuth } from &#39;@supabase/auth-helpers-sveltekit&#39;
import { redirect } from &#39;@sveltejs/kit&#39;
import type { PageLoad } from &#39;./$types&#39;

export const load: PageLoad = withAuth(async ({ session, getSupabaseClient }) =&gt; {
  if (!session.user) {
    throw redirect(303, &#39;/&#39;)
  }

  const { data: tableData } = await getSupabaseClient().from(&#39;test&#39;).select(&#39;*&#39;)
  return { tableData, user: session.user }
})</code>
  </pre>
  </div>


</div>


</div>
<h3 id="withapiauth">withApiAuth <a href="#withapiauth" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h3>
<nav>
	<div class="nav nav-tabs" id="nav-tab" role="tablist">

		
		
		
		

		

		<a class="nav-link  active"
		   id="fedcabTab" data-bs-toggle="tab" data-bs-target="#fedcab"
		   type="button" role="tab" aria-controls="fedcab" aria-selected="true">0.6.11 and below</a>

		

		<a class="nav-link "
		   id="fedabcTab" data-bs-toggle="tab" data-bs-target="#fedabc"
		   type="button" role="tab" aria-controls="fedabc" aria-selected="true">0.7.0</a>

		

	</div>
</nav>

<div class="tab-content" id="nav-tab-content">

	






<div class="tab-pane fade show active" id="fedcab" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="ea468dc" class="language-ts ">
  <code>import { supabaseServerClient, withApiAuth } from &#39;@supabase/auth-helpers-sveltekit&#39;
import type { RequestHandler } from &#39;./__types/protected-route&#39;

interface TestTable {
  id: string
  created_at: string
}

interface GetOutput {
  data: TestTable[]
}

export const GET: RequestHandler&lt;GetOutput&gt; = async ({ locals, request }) =&gt;
  withApiAuth({ user: locals.user }, async () =&gt; {
    // Run queries with RLS on the server
    const { data } = await supabaseServerClient(request).from(&#39;test&#39;).select(&#39;*&#39;)

    return {
      status: 200,
      body: { data },
    }
  })</code>
  </pre>
  </div>


</div>






<div class="tab-pane fade" id="fedabc" role="tabpanel" aria-labelledby="nav-1">

	


  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="a1f51bc" class="language-ts ">
  <code>import type { RequestHandler } from &#39;./$types&#39;;
import { withAuth } from &#39;@supabase/auth-helpers-sveltekit&#39;;
import { json, redirect } from &#39;@sveltejs/kit&#39;;

interface TestTable {
  id: string;
  created_at: string;
}

export const GET: RequestHandler = withAuth(async ({ session, getSupabaseClient }) =&gt; {
  if (!session.user) {
    throw redirect(303, &#39;/&#39;);
  }

  const { data } = await getSupabaseClient()
    .from&lt;TestTable&gt;(&#39;test&#39;)
    .select(&#39;*&#39;);

  return json({ data });
);</code>
  </pre>
  </div>


</div>


</div>
<h2 id="其他链接">其他链接 <a href="#%e5%85%b6%e4%bb%96%e9%93%be%e6%8e%a5" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><ul>
<li><a href="https://github.com/supabase/auth-helpers" rel="external" target="_blank">身份验证帮助程序源代码<svg width="16" height="16" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M14 5c-.552 0-1-.448-1-1s.448-1 1-1h6c.552 0 1 .448 1 1v6c0 .552-.448 1-1 1s-1-.448-1-1v-3.586l-7.293 7.293c-.391.39-1.024.39-1.414 0-.391-.391-.391-1.024 0-1.414l7.293-7.293h-3.586zm-9 2c-.552 0-1 .448-1 1v11c0 .552.448 1 1 1h11c.552 0 1-.448 1-1v-4.563c0-.552.448-1 1-1s1 .448 1 1v4.563c0 1.657-1.343 3-3 3h-11c-1.657 0-3-1.343-3-3v-11c0-1.657 1.343-3 3-3h4.563c.552 0 1 .448 1 1s-.448 1-1 1h-4.563z"/></svg></a></li>
<li><a href="https://github.com/supabase/auth-helpers/tree/main/examples/sveltekit" rel="external" target="_blank">SveltKit示例<svg width="16" height="16" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M14 5c-.552 0-1-.448-1-1s.448-1 1-1h6c.552 0 1 .448 1 1v6c0 .552-.448 1-1 1s-1-.448-1-1v-3.586l-7.293 7.293c-.391.39-1.024.39-1.414 0-.391-.391-.391-1.024 0-1.414l7.293-7.293h-3.586zm-9 2c-.552 0-1 .448-1 1v11c0 .552.448 1 1 1h11c.552 0 1-.448 1-1v-4.563c0-.552.448-1 1-1s1 .448 1 1v4.563c0 1.657-1.343 3-3 3h-11c-1.657 0-3-1.343-3-3v-11c0-1.657 1.343-3 3-3h4.563c.552 0 1 .448 1 1s-.448 1-1 1h-4.563z"/></svg></a></li>
<li><a href="https://github.com/supabase/auth-helpers/tree/main/examples/sveltekit-email-password" rel="external" target="_blank">SveltKit电子邮件/密码示例<svg width="16" height="16" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M14 5c-.552 0-1-.448-1-1s.448-1 1-1h6c.552 0 1 .448 1 1v6c0 .552-.448 1-1 1s-1-.448-1-1v-3.586l-7.293 7.293c-.391.39-1.024.39-1.414 0-.391-.391-.391-1.024 0-1.414l7.293-7.293h-3.586zm-9 2c-.552 0-1 .448-1 1v11c0 .552.448 1 1 1h11c.552 0 1-.448 1-1v-4.563c0-.552.448-1 1-1s1 .448 1 1v4.563c0 1.657-1.343 3-3 3h-11c-1.657 0-3-1.343-3-3v-11c0-1.657 1.343-3 3-3h4.563c.552 0 1 .448 1 1s-.448 1-1 1h-4.563z"/></svg></a></li>
<li><a href="https://github.com/supabase/auth-helpers/tree/main/examples/sveltekit-magic-link" rel="external" target="_blank">SveltKit Magiclink示例<svg width="16" height="16" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M14 5c-.552 0-1-.448-1-1s.448-1 1-1h6c.552 0 1 .448 1 1v6c0 .552-.448 1-1 1s-1-.448-1-1v-3.586l-7.293 7.293c-.391.39-1.024.39-1.414 0-.391-.391-.391-1.024 0-1.414l7.293-7.293h-3.586zm-9 2c-.552 0-1 .448-1 1v11c0 .552.448 1 1 1h11c.552 0 1-.448 1-1v-4.563c0-.552.448-1 1-1s1 .448 1 1v4.563c0 1.657-1.343 3-3 3h-11c-1.657 0-3-1.343-3-3v-11c0-1.657 1.343-3 3-3h4.563c.552 0 1 .448 1 1s-.448 1-1 1h-4.563z"/></svg></a></li>
</ul>

    </div>

    

    
                                            </div>
                                            <div><hr class="doc-hr">
<div id="doc-nav" class="d-print-none">

	<div class="row flex-xl-nowrap ">
	<div class="col-sm-6 pt-2 doc-next">
		<a href="../nextjs/index.html">
			<div class="card h-100 my-1">
				<div class="card-body py-2">
                    <p class="card-title fs-5 fw-semibold lh-base mb-0"><i class="material-icons align-middle">navigate_before</i> 使用Next.js进行Supabase认证</p>
					
				</div>
			</div>
		</a>
        </div>
	<div class="col-sm-6 pt-2 doc-prev">
		<a class="ms-auto" href="../remix/index.html">
			<div class="card h-100 my-1 text-end">
				<div class="card-body py-2">
                    <p class="card-title fs-5 fw-semibold lh-base mb-0">Supabase Remix认证 <i class="material-icons align-middle">navigate_next</i></p>
					
				</div>
			</div>
		</a>
        </div>
	</div>
</div></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
<footer class="shadow py-3 d-print-none">
    <div class="container-fluid">
        <div class="row align-items-center">
            <div class="col">
                <div class="text-sm-start text-center mx-md-2">
                    <p class="mb-0">
                        
                        
                    </p>
                </div>
            </div>
        </div>
    </div>
</footer>
</main>
            </div>
        </div>

        
        
        <button onclick="topFunction()" id="back-to-top" aria-label="Back to Top Button" class="back-to-top fs-5"><svg width="24" height="24"><path d="M12,10.224l-6.3,6.3L4.32,15.152,12,7.472l7.68,7.68L18.3,16.528Z" style="fill:#fff"/></svg></button>
        
        

        
        
            <script>(()=>{var e=document.getElementById("mode");e!==null&&(window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",e=>{e.matches?(localStorage.setItem("theme","dark"),document.documentElement.setAttribute("data-dark-mode","")):(localStorage.setItem("theme","light"),document.documentElement.removeAttribute("data-dark-mode"))}),e.addEventListener("click",()=>{document.documentElement.toggleAttribute("data-dark-mode"),localStorage.setItem("theme",document.documentElement.hasAttribute("data-dark-mode")?"dark":"light")}),localStorage.getItem("theme")==="dark"?document.documentElement.setAttribute("data-dark-mode",""):document.documentElement.removeAttribute("data-dark-mode"))})()</script>
        




    
        
        
    
    






    

    <script src="../../../../../js/bootstrap.eac7ee3f6fa791c684e7a51fc2fd50b6f724271b9e39562e4fe8c3942412df3acbfc4045f043d03399dac70091207507.js"  defer></script>


    <script type="text/javascript" src="../../../../../js/bundle.min.ad2cedf5bf6173166579295b890c8a020e465c578d1a8833a9fad762c06e1e5133eb6f348c2644eb0bacfc38149db152.js"   crossorigin="anonymous" defer></script>
        

        
        
    </body>

<!-- Mirrored from docs.memfiredb.com/docs/app/development_guide/auth/auth-helpers/sveltekit/ by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 27 Jun 2025 07:54:01 GMT -->
</html>